﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	HtmlTemplateConverter.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System.Collections.Generic;
using Smart.Common.Entities;

namespace Smart.Common.Templates
{
	public class HtmlTemplateConverter : TemplateConverter
	{
		public HtmlTemplateConverter(TemplateCtx ctx)
			: base(ctx)
		{
		}

		public override void LoadUserValuesToCtx(IDictionary<string, object> values)
		{
			if (values == null)
				return;

			foreach (var kvp in values)
			{
				if (kvp.Value is LinkValue)
					Ctx.Values[kvp.Key] = ((LinkValue)kvp.Value).GetLink();
				else if (kvp.Value is UserValue)
					Ctx.Values[kvp.Key] = ((UserValue)kvp.Value).GetUserLink();
				else
					Ctx.Values[kvp.Key] = kvp.Value;
			}
		}

		public override void LoadTemplateValuesToCtx()
		{
			// Do nothing: no template values stored
		}
	}
}